package cn.itcalvin.sncoal.cth.pojo.response.minio;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import jdk.nashorn.internal.ir.annotations.Ignore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class RespListFileItem {
    @ApiModelProperty(value = "文件名称")
    private String fileName;

    private String fileUrl;

    @ApiModelProperty(value = "文件URL")
    private String fileUrlStr;
    @ApiModelProperty(value = "是否是文件夹")
    private Boolean isDir;
    @ApiModelProperty(value = "文件大小")
    private Long size;

    @ApiModelProperty(value = "最后修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date lastModified;

    /**
     * 隐藏前面两级
     * @return
     */
    public String getFileUrlStr() {
        if(fileUrl==null){
            return null;
        }
        return fileUrl.replaceAll("^([^/]*/[^/]*)/", "");
    }
}
